<template>
  <view class="benben-image-upload-item">
    <image @tap.stop="handImage" :lazy-load="lazyLoad" :show-menu-by-longpress="showMenuByLongpress" :src="src"
      :mode="mode" />
  </view>
</template>
<script>
export default {
  name: 'benben-image-item',
  props: {
    src: {
      type: [String],
      default: '',
    },
    lazyLoad: {
      type: [Boolean],
      default: false,
    },
    showMenuByLongpress: {
      type: [Boolean],
      default: false,
    },
    mode: {
      type: [String],
      default: 'aspectFit',
    },
    handIndex: {
      type: [String, Number],
      default: 'null',
    },
    handName: {
      type: String,
      default: '',
    },
    handMethod: {
      type: String,
      default: '',
    },
  },
  options: {
    styleIsolation: "shared"
  },
  components: {},
  //监听value
  watch: {
  },
  computed: {

  },
  data: () => ({

  }),
  methods: {
    handImage() {
      let benbenImagesUpload = this.getCollapse(this.handName)
      if (this.handMethod && benbenImagesUpload[this.handMethod]) {
        if (this.handIndex !== 'null') {
          benbenImagesUpload[this.handMethod](this.handIndex)
        } else {
          benbenImagesUpload[this.handMethod]()
        }
      }
    },
    getCollapse(name) {
      let parent = this.$parent
      let parentName = parent.$options.name
      while (parentName !== name) {
        parent = parent.$parent
        if (!parent) return false
        parentName = parent.$options.name
      }
      return parent
    },

  },
  created() { },
}
</script>
<style lang="scss" scoped>
/* #ifndef MP-WEIXIN */
image {
  border-radius: inherit;
  width: 100%;
  height: 100%;
}
/* #endif */
/* #ifdef MP-WEIXIN */
.benben-image-upload-item {
  width: inherit;
  height: inherit;
  border-radius: inherit;

  image {
    border-radius: inherit;
    width: inherit;
    height: inherit;
  }
}
/* #endif */
</style>
